/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package calculadorfpa.tablemodels;

import calculadorfpa.modelo.CaracteristicaGeral;
import calculadorfpa.modelo.DescricaoComplexidadeHelper;
import calculadorfpa.modelo.NivelInfluencia;
import java.util.Iterator;
import java.util.Map;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author TECBMEPI
 */
public class TableModelRelatorio extends AbstractTableModel {

    private Map<CaracteristicaGeral, NivelInfluencia> mapa;
    private String[] columnNames = {"Característica", "Nível de Influência"};
    private Object[][] data = null;

    public TableModelRelatorio(Map<CaracteristicaGeral, NivelInfluencia> mapa) {
        this.mapa = mapa;
        populaMapa();
    }

    private void populaMapa() {
        data = new Object[mapa.size()][2];
        Iterator<CaracteristicaGeral> caracteristicas = mapa.keySet().iterator();
        int rowCount = 0;
        while(caracteristicas.hasNext()) {
            CaracteristicaGeral caracteristica = caracteristicas.next();
            data[rowCount][0] = caracteristica.getDescricao();
            data[rowCount][1] = mapa.get(caracteristica).getValor();
            rowCount++;
        }
    }

    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    public int getRowCount() {
        return data.length;
    }

    public int getColumnCount() {
        return columnNames.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        return data[rowIndex][columnIndex];
    }
}
